#while实现
#1
row=1
while row < 10:
    col = 1
    while col <row+1:
        print('{}*{}={:<4}'.format(row, col, row * col), end=' ')
        col+=1
    print('')
    row+=1
print('='*100)
print('')

#2
row=9
while row>0:
    col=1
    while col<row+1:
        print('{}*{}={:<4}'.format(row, col, row * col), end=' ')
        col+=1
    print('')
    row-=1
print('='*100)
print('')

#3
row=1
while row<10:
    col=1
    while col<10:
        if col <= 9 - row:
            print('{:<8}'.format(' '), end=' ')
        else:
            print('{}*{}={:<4}'.format(10 - col, row, (10 - col) * row), end=' ')
        col+=1
    print('')
    row+=1
print('='*100)
print('')

#4
row=9
while row>0:
    col=9
    while col>0:
        if col > row:
            print('{:<8}'.format(' '), end=' ')
        else:
            print('{}*{}={:<4}'.format(col, row, col * row), end=' ')
        col-=1
    print('')
    row-=1
print('='*100)
print('')

#for实现
#1
for row in range(1,10):
    for col in range(1,row+1):
        print('{}*{}={:<4}'.format(row,col,row*col),end=' ')
    print('')
print('='*100)
print('')

#2
for row in range(9,0,-1):
    for col in range(1,row+1):
        print('{}*{}={:<4}'.format(row,col,row*col),end=' ')
    print('')
print('='*100)
print('')

#3
for row in range(1,10):
    for col in range(1,10):
        if col <= 9-row:
            print('{:<8}'.format(' '),end=' ')
        else:
            print('{}*{}={:<4}'.format(10-col,row,(10-col)*row),end=' ')
    print('')
print('='*100)
print('')

#4
for row in range(9,0,-1):
    for col in range(9,0,-1):
        if col > row:
            print('{:<8}'.format(' '),end=' ')
        else:
            print('{}*{}={:<4}'.format(col,row,col*row),end=' ')
    print('')

print('='*100)
print('')






